// pages/template/setting/setting.js
const app = getApp()
const api = require('../../utils/util.js')
const service = require('../../utils/service.js')

Component({
  properties: {

  },
  data: {
    // 这里是一些组件内部数据
    setting: true,
    canIUse: wx.canIUse('button.open-type.getUserInfo')
  },
  pageLifetimes: {
    show: function () {
      let _this = this;
      wx.getSetting({
        success: res => {
          if (res.authSetting['scope.userInfo']) {
            _this.setData({
              setting: true
            })
          } else {
            _this.setData({
              setting: false
            })
          }
        },
        fail: res => {

        }
      })
    }
  },
  methods: {
    /**点击开启授权 */
    bindGetUserInfo: function (e) {
      var _this = this;
      var userInfo = e.detail.userInfo;

      var encryptedData = e.detail.encryptedData;
      var iv = e.detail.iv;

      api.shopGetUserInfo(encryptedData, iv);
      _this.setData({
        setting: true
      })

    },
  }
})
